﻿@page "/"
@using System.Threading
@using WebsiteForWorkFlow.Data
<h1>Hello, world!</h1>

API Result
<br>
<input type="text" @bind="@DataInstance.Result">

<br>
<br>
<input type="text" value="@_WorkFlowName">
<button class="btn btn-primary" @onclick="()=>StartWorkFlow()">Start WorkFlow</button>
<br>
<br>
<textarea style="width:100%; height:500px;" @bind="@DataInstance.ShowMessage"></textarea>

@code
{
    string _WorkFlowName = "TestWorkFlow";
    protected override void OnAfterRender(bool firstRender)
    {
        base.OnAfterRender(firstRender);
        if (firstRender)
        {
            new Timer(new TimerCallback(_ =>
            {
                InvokeAsync(() => StateHasChanged());
            }
            ), null, 1000, 1000);
        }
    }
    void StartWorkFlow()
    {
        Dictionary<string, string> workFlowDirectory = new Dictionary<string, string>();
        workFlowDirectory.Add("WorkFlowID", "4");
        workFlowDirectory.Add("InitUser", "InitUser");
        workFlowDirectory.Add("User", "TestUser");
        workFlowDirectory.Add("Parameter1", "aaa");
        workFlowDirectory.Add("Parameter2", "bbb");
        workFlowDirectory.Add("Parameter3", "ccc");
        bool result = WorkFlowTool.StartWorkFlow(workFlowDirectory);
    }
}